﻿Option Strict On
Imports System.Drawing

Partial Class Pages_Site
    Inherits System.Web.UI.MasterPage

    Protected Sub CalendarEvent_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles CalendarEvent.DayRender

        'byter färg på dagens datum
        'Dim vacationStyle As New Style()
        'With vacationStyle
        '    .BackColor = System.Drawing.Color.Yellow
        '    .BorderColor = System.Drawing.Color.Purple
        '    .BorderWidth = New Unit(3)
        'End With

        'Calendar.TodayDayStyle.BackColor = Drawing.Color.LightPink
        'Dim myAppointment As Date = New Date(2011, 4, 18)

        'If (e.Day.Date = myAppointment) Then
        '    e.Day.IsSelectable = True


        'Else
        '    e.Day.IsSelectable = False
        'End If

        Dim eventList As List(Of Calendar) = New CalendarDAO().getAllEvents()
        Dim Calendar = New Calendar

        Try
            Dim myAppointment As Date = eventList.FirstOrDefault(Function(c) c.DateEvent.ToString("yyyy/MM/dd") = e.Day.Date.ToString("yyyy/MM/dd")).DateEvent
            e.Day.IsSelectable = True

            'e.Cell.ClientID = Calendar.AppointmentID

        Catch ex As Exception
            e.Day.IsSelectable = False
        End Try


    End Sub

    Protected Sub CalendarEvent_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CalendarEvent.SelectionChanged
        'Händer när man klickar på ett datum
        Dim CalendarDAO = New CalendarDAO().getAllEvents
        Dim calendar = New Calendar

        'Fixa så att kalender dagarna får ett ID, eventuellt gå bakvägen. Vid klick kollar den 
        'med en funktion datumen och tar ID
        Response.Redirect("~/Pages/Sparetime/Evenemangskalender.aspx?dateevent=" & CalendarEvent.SelectedDate())

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Sätter Rubriken på en kalenderEvent
        rptEvents.DataSource = New CalendarDAO().getAllEvents
        rptEvents.DataBind()

        'För att menyn ska byta färg efter url
        Dim a As String = Request.Url.AbsolutePath()

        'If a.Contains("Default.aspx") Then
        '    Dim htmlColor As String = "#0377b0"
        '    Dim myColor As Color = ColorTranslator.FromHtml(htmlColor)
        '    hypDefault.BackColor = myColor
        'End If

        'If (a).Contains("Sparetime.aspx") Then
        '    Dim htmlColor As String = "#57d16c"
        '    Dim myColor As Color = ColorTranslator.FromHtml(htmlColor)
        '    hypSparetime.BackColor = myColor
        'End If

        'If (a).Contains("School.aspx") Then
        '    Dim htmlColor As String = "#a9e4f4"
        '    Dim myColor As Color = ColorTranslator.FromHtml(htmlColor)
        '    hypSchool.BackColor = myColor
        'End If

        'If (a).Contains("Work.aspx") Then
        '    Dim htmlColor As String = "#fb9e4e"
        '    Dim myColor As Color = ColorTranslator.FromHtml(htmlColor)
        '    hypWork.BackColor = myColor
        'End If

        'If (a).Contains("Help.aspx") Then
        '    Dim htmlColor As String = "#fb7b6e"
        '    Dim myColor As Color = ColorTranslator.FromHtml(htmlColor)
        '    hypHelp.BackColor = myColor
        'End If

        'If (a).Contains("Project.aspx") Then
        '    Dim htmlColor As String = "#fff451"
        '    Dim myColor As Color = ColorTranslator.FromHtml(htmlColor)
        '    hypProject.BackColor = myColor
        'End If

        'If (a).Contains("FAQ.aspx") Then
        '    Dim htmlColor As String = "#121211"
        '    Dim myColor As Color = ColorTranslator.FromHtml(htmlColor)
        '    hypFAQ.BackColor = myColor
        'End If

        'Hide the next/previous months
        'Dim calender As New Calendar
        'Calendar.ShowNextPrevMonth = False

    End Sub

End Class

